package org.example;
//具体原型类
/**
 * @Description java已经实现clone方法，所以原型在java中实现较为简单，
 * 借鉴到单例模式，原型也可以拓展出带有管理器的原型模式  ProtoTypeShape.java中实现
 *
 * @Date 9:50 2022/7/27
 * @Author sunye
 */
class Realizetype implements Cloneable {

    @Override
    protected Object clone() throws CloneNotSupportedException {
        System.out.println("具体原型复制成功！");
        return super.clone();
    }
}

//原型模式的测试类
public class PrototypeTest {
    public static void main(String[] args) throws CloneNotSupportedException {
        Realizetype obj1 = new Realizetype();
        Realizetype obj2 = (Realizetype) obj1.clone();
        System.out.println("obj1==obj2?" + (obj1 == obj2));
    }
}